<% content_for :head do -%>
  <script type="text/javascript" src="http://www.google.com/jsapi?key=<%= API_KEYS['gmkey'] %>"></script>
  <script type="text/javascript">
    google.load("maps", "2.x");
  </script>
<% end -%>



<div id="breadcrumb">
  <a href="/">inicio</a> <%= link_to  @event.title, event_url(@event) %>
</div>

<div class="whitebox">
  <div class="cont clearfix">
    <h2><%= @event.get_title %> <span>creado por <%= link_to @event.user.public_name, user_home_url(@event.user.login) %></span></h2>
    <div id="icol" class="clearfix">
      <div class="col">
        <div class="greybox">
          <div class="cont">
            <strong>
            <%= @event.starts_at.extralong_first %><br/>
            <%= @event.starts_at.extralong_last %><br/>
            <%= @event.starts_at.time %>h.
            </strong>
            <% unless @event.ends_at.blank? %>
              <strong>
                <br/><br/>
                hasta el 
                <%= @event.starts_at.extralong_first %><br/>
                <%= @event.starts_at.extralong_last %><br/>
                <%= @event.starts_at.time %>h.<br/>
              </strong>
            <% end %>
          </div>
        </div>
        <div id="description">
          <%= simple_format(@event.description) %>
        </div>
      </div><!-- .col -->
      <div class="col">
        <% unless @event.place.nil? %>
          <strong class="notes">¿Dónde?</strong>
          <h3><%= @event.place.name %></h3>
          <p class="notes"><%= @event.place.address %><br/>
          <%= @event.place.city %> <%= "-" unless @event.place.state.blank? && @event.place.city.blank? %> <%= @event.place.state %><br/>
          <%= @event.place.country.name %>
          </p>
          <% unless @event.place.latitude.blank? || @event.place.longitude.blank? %>
            <div id="map" style="width:270px; height:150px">
            </div>
            <script type="text/javascript" charset="utf-8">
              initialize_map(<%= @event.place.latitude %>, <%= @event.place.longitude %>)
            </script>
          <% end %>
          <% if logged_in? %>
          <p>
            <%= image_tag 'ajaxload.gif', {:id => 'loadplace', :style => "display:none"} %>
            <span id="send_sms"><%= link_to_remote 'Envíame un SMS con los datos', {:url => {:action => 'sms_event', :id => @event.id }, :confirm => "Te vamos a enviar un SMS con los datos a tu móvil, que es el #{current_user.mobile}", :loading => "$('loadplace').show(); $('send_sms').hide();" } %></span>
          </p>
          <% end %>
        <% end %>
      </div><!-- .col -->
      <div class="col">
        
        <% if @event.confirmations.size > 0 %>
        <strong class="notes">¿Quién viene?</strong>
        <ul class="avatars clearfix">
        <% @event.confirmations.each do |contact| %>
          <li>
            <%= link_to image_tag(contact.avatar(:thumb), :alt => contact.get_name, :title => contact.get_name), user_home_url(contact.user.login) %>
          </li>
        <% end %>
        </ul>
        <div class="separata"></div>
        <% end %>
        
        
        <% if @event.denegations.size > 0 %>
        <strong class="notes">¿Quién no viene?</strong>
        <ul class="avatars clearfix">
        <% @event.denegations.each do |contact| %>
          <li>
            <%= link_to image_tag(contact.avatar(:thumb), :alt => contact.get_name, :title => contact.get_name), user_home_url(contact.user.login) %>
          </li>
        <% end %>
        </ul>
        <div class="separata"></div>
        <% end %>
        
        <% if @event.invitations.size > 0 %>
        <strong class="notes">Invitados por confirmar: </strong> <%= @event.invitations.size %>
        <br/><br/>
        <div class="separata"></div>
        <% end %>
        
        
        <%= link_to 'Enviar más invitaciones', event_invite_url(@event), :class => "yellowbutton" if logged_in? and current_user.id == @event.user_id %>
        <%= link_to 'Apuntarme a este evento', {:action => 'add_user_to_event', :id => @event}, :class => "orangebutton" unless @event.private? || (logged_in? ? current_user.has_event?(@event) : false) %>
      </div><!-- .col -->
    </div>
  </div><!-- .cont -->
</div><!-- .whitebox -->
<br/>
<div class="clearfix">
  <div class="col1_2">
    <div class="whitebox" id="comments">
      <div class="cont clearfix">
        <h2>Comentarios</h2>
        <div id="contcomments">
          <%= render :partial => "comments" %>
        </div>
      </div><!-- .cont -->
    </div><!-- .whitebox -->

  </div>

  <div class="col2_2">
    <div class="whitebox">
      <div class="cont clearfix">
        <h2>Imágenes</h2>
        <p>Envíanos imágenes sobre el evento mediante un mail <a href="mailto:tvienes@gmail.com">tvienes@gmail.com</a> poniendo <strong><%= @event.id %></strong> en el subject.</p>
        <ul class="avatars">
          <% @event.event_images.each do |image|%>
            <li><%= image_tag image.public_filename(:thumb), :width => 80 %></li>
          <% end %>
        </ul>
      </div><!-- .cont -->
    </div><!-- .whitebox -->
  </div>
</div>